/**
 * .
 *
 * .
 *
 * .
 */

package com.songbl.bless.app.controller;


import com.songbl.bless.app.entity.UserEntity;
import com.songbl.bless.app.form.LoginForm;
import com.songbl.bless.app.job.AcceptPersn;
import com.songbl.bless.app.job.ScheduleUtils;
import com.songbl.bless.app.service.BlessInfoService;
import com.songbl.bless.app.service.UserService;
import com.songbl.bless.app.util.JwtUtils;
import com.songbl.bless.common.utils.DateUtils;
import com.songbl.bless.common.utils.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/app")
public class SendMailController {
    private static Logger logger = LoggerFactory.getLogger(SendMailController.class);
    @Autowired
    ScheduleUtils scheduleUtils ;

    @Autowired
    BlessInfoService blessInfoService ;

    /**
     * 发送邮件
     */
    @PostMapping("sendMail")
    public R sendMail(@RequestBody AcceptPersn persn){
        System.out.println("登录原始数据 "+persn.toString());
        persn.setSubject("祝福邮件");
        persn.setTo("sbl19940819@163.com");
        String blessInfoContent = blessInfoService.getBlessOneInfo(persn.getId()).getInfoContents();
        persn.setContent(blessInfoContent);

        scheduleUtils.createScheduleJob(DateUtils.stringToDate(persn.getDate(),"yyyy-MM-dd HH:mm:ss"),persn);

        Map<String, Object> map = new HashMap<>();
        map.put("result",true);

        return R.ok(map);
    }

}
